<?php
	class FlinkController extends CommonController{
		private $model;
		public function __init(){
			$this->model=K('flink');
		}
		public function index(){
			$this->assign('flink',$this->model->allData());
			$this->display();
		}
		public function add(){
			if(IS_POST){
				if($this->model->addData()){
					$this->success('添加成功');
				}else{
					$this->error('添加失败');
				}
			}else{
				$this->display();
			}
		}
		public function upload()
	    {
	        $upload = new Upload('Upload/Flink/' . date('y/m'));
	        $file = $upload->upload();
	        if (empty($file)) {
	            $this->ajax('上传失败');
	        } else {
	            $data = $file[0];
	            $this->ajax($data);
	        }
	    }
	    public function edit(){
	    	if(IS_POST){
	    		if($this->model->editData()){
	    			$this->success('修改成功');
	    		}else{
	    			$this->error('修改失败');
	    		}
	    	}else{
	    		$data=$this->model->oneData();
	    		// p($data);
	    		$this->assign('data',$data);
	    		$this->display();
	    	}
	    }
	    public function del(){
	    	if($this->model->delData()){
	    		$this->success('删除成功');
	    	}else{
	    		$this->error('删除失败');
	    	}
	    }
	}
?>